#!/bin/csh 
####################################################################################
## Creat large-forcing data for SPARTICUS 
## 
## Original data from ARM website: 
## http://www.arm.gov/news/data/post/20319 
##
## Steps: 
## 
## (1) Change variable name 
## (2) Change units 
## (3) Change additional information 
## 
## See scm_forcing_format.ncl for details  
## 
## Author: Kai Zhang (kai.zhang@pnnl.gov) 
## 
####################################################################################


###########################
## March 
###########################

 rm -f sgp_20100301_cam5_v2.nc 
 rm -f tmp_20100301_cam5.nc 
 
 ncrcat -v lat,lon -x v2_sgp_20100301.nc tmp_20100301_cam5.nc
 cdo invertlev tmp_20100301_cam5.nc sgp_20100301_cam5_v2.nc 

cat > loadit << EOF
  fna = "sgp_20100301_cam5_v2.nc"
EOF

 ncl scm_forcing_format.ncl


###########################
## April 
###########################

 rm -f sgp_20100401_cam5_v2.nc 
 rm -f tmp_20100401_cam5.nc 

 ncrcat -v lat,lon -x v2_sgp_20100401.nc tmp_20100401_cam5.nc
 cdo invertlev tmp_20100401_cam5.nc sgp_20100401_cam5_v2.nc 

cat > loadit << EOF
  fna = "sgp_20100401_cam5_v2.nc"
EOF

 ncl scm_forcing_format.ncl


###########################
## May 
###########################

 rm -f sgp_20100501_cam5_v2.nc
 rm -f tmp_20100501_cam5.nc

 ncrcat -v lat,lon -x v2_sgp_20100501.nc tmp_20100501_cam5.nc
 cdo invertlev tmp_20100501_cam5.nc sgp_20100501_cam5_v2.nc

cat > loadit << EOF
  fna = "sgp_20100501_cam5_v2.nc"
EOF

 ncl scm_forcing_format.ncl


###########################
## Merge files 
###########################

 rm -f tmp_2010_cam5.nc 
 rm -f sgp_2010_cam5_v2.nc 

 cdo mergetime sgp_20100301_cam5_v2.nc sgp_20100401_cam5_v2.nc sgp_20100501_cam5_v2.nc tmp_2010_cam5.nc 

 ncrcat -v lat,lon,tsec,lev -x tmp_2010_cam5.nc sgp_2010_cam5_v2.nc 

 ncl scm_forcing_format_merge.ncl


